<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/admin/jsp/taglibs.jsp"%>
<html>
	<head>
		<%@ include file="/admin/jsp/header.jsp"%>
		<%@ include file="/framework/jsp/validation.jsp"%>
		<script language="javascript" src="/framework/js/tips_alert.js"></script>
		<%@ include file="/framework/jsp/calendar.jsp"%>
	</head>
	<body>
		<table width="98%" border="0" align="center" cellpadding="3" cellspacing="0">
			<tr>
				<td class="page-title">
					<img src="../images/page_title.gif" alt="title" width="17" height="12" align="absmiddle">
					&nbsp;&nbsp; 组织管理 » 用户管理 » 用户修改
				</td>
			</tr>
		</table>
		<br>
		<form id="form" action="/admin/jsp/userMgr.do?method=updUser" method="post" onsubmit="_getSelected()">
			<input type="hidden" name="systemId" id="systemId" value="${systemType}"/>
			<input type="hidden" name="loginId" id="loginId" value="${resultObject.loginId}">
			<input type="hidden" name="systemType" id="systemType" value="${systemType}"/>
			<table width="50%" border="0" cellpadding="5" cellspacing="0">
				<tr>
					<td></td>
					<td align="left">带<font color="red">&nbsp;*&nbsp;</font>为必填项</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户姓名
					</td>
					<td>
						<input name="userName" class="required max-length-10" type="text" id="userName" size="20" value="<c:out value='${resultObject.userName}'/>">
						<a href="#"><img src="../images/help.gif" tips="用户姓名，10字以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户帐号
					</td>
					<td>
						<input name="loginName" class="required max-length-20" type="text" id="loginName" size="20" value="<c:out value='${resultObject.loginName}'/>">
						<a href="#"><img src="../images/help.gif" tips="用户帐号，最长20个字符" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户密码
					</td>
					<td>
						<input name="loginPwd" class="required min-length-6 max-length-15" type="password" id="loginPwd" size="20" value="<c:out value='${resultObject.loginPwd}'/>">
						<a href="#"><img src="../images/help.gif" tips="密码，6至15位英文、数字或符号" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>确认密码
					</td>
					<td>
						<input name="repLoginPwd" class="required equals-loginPwd" type="password" size="20" value="<c:out value='${resultObject.loginPwd}'/>">
						<a href="#"><img src="../images/help.gif" tips="请再次输入上面的密码" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户类型
					</td>
					<td>
						<select name="userType" id="userType">
							<option value="1">管理员</option>
							<option value="2">操作员</option>
						</select>
						<a href="#"><img src="../images/help.gif" tips="用户类型" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>所属单位
					</td>
					<td>
						<select name="corpId" id="corpId" class="validate-one-checked">
							<c:forEach var="corp" items="${corpList}">
								<option value="<c:out value='${corp.corpId}'/>"><c:out value="${corp.corpName}"/></option>
							</c:forEach>
						</select>
						<a href="#"><img src="../images/help.gif" tips="用户所属单位" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>是否永久生效
					</td>
					<td>
						<select name="validTag" id="validTag" class="validate-one-checked" onchange="changeValidTag(this.value);">
							<option value="Y">是</option>
							<option value="N">否</option>
						</select>
						<a href="#"><img src="../images/help.gif" tips="是否永久生效" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr id="validDateTr">
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>有效日期
					</td>
					<td>
						<input type="text" name="validDate" id="validDate" class="required max-length-10" size="20" value="<c:out value='${resultObject.validDate}'/>" readonly>
							&nbsp;
						<img id="startBtn" style="cursor: hand" src="../images/calendar.gif" />	
						<a href="#"><img src="../images/help.gif" tips="有效日期，10字以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						手机号码
					</td>
					<td>
						<input name="terminalId" class="validate-mobile-phone" type="text" id="terminalId" size="20" value="<c:out value='${resultObject.terminalId}'/>">
						<a href="#"><img src="../images/help.gif" tips="输入11位手机号码" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						联系电话
					</td>
					<td>
						<input name="tel" class="validate-phone" type="text" id="tel" size="20" value="<c:out value='${resultObject.tel}'/>">
						<a href="#"><img src="../images/help.gif" tips="联系电话，21字符以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>Email
					</td>
					<td>
						<input name="email" class="required validate-email" type="text" id="email" size="20" value="<c:out value='${resultObject.email}'/>">
						<a href="#"><img src="../images/help.gif" tips="Email，100字以内"
								width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户角色
					</td>
					<td>
						<c:forEach var="role" items="${roleList}">
							<input class="validate-one-required" type="checkbox"
								name="roles" value="${role.roleId}">
							<c:out value="${role.roleName}" />
						</c:forEach>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						用户描述
					</td>
					<td>
						<textarea name="userRemark" rows="4" cols="20" id="userRemark" class="max-length-200"><c:out value='${resultObject.userRemark}'/></textarea>
						<a href="#"><img src="../images/help.gif" tips="用户描述，200字以内" width="14" height="15" border="0" align="absmiddle"> </a>
					</td>
				</tr>
				<tr>
					<td align="right" valign="middle">
						<font color="red">*&nbsp;</font>用户状态
					</td>
					<td>
						<input name="status" class="validate-one-required" type="radio" id="status" value="1">
						有效
						<input name="status" class="validate-one-required" type="radio" id="status" value="0">
						无效
					</td>
				</tr>
				<tr>
					<td align="center" valign="middle" colspan="2">
						<input type="submit" class="short-button" value="提  交" />&nbsp;&nbsp;
						<input type="button" class="short-button" value="返  回" onclick="window.location='/admin/jsp/userMgr.do?method=queryUser&systemType=${systemType}'" />
					</td>					
				</tr>
			</table>	
		</form>
	</body>
	<script>
		new Validation('form',{immediate:true});
		setObjSelected('corpId','${resultObject.corpId}');
		setObjSelected('userType','${resultObject.userType}');
		setObjSelected('validTag','${resultObject.validTag}');
		setCheckboxCheckedValue('roles','${resultObject.roleIds}');
		checkedRadio('status','${resultObject.status}');
		
		Calendar.setup(
		{
	      	inputField  : "validDate",      // ID of the input field
	      	ifFormat    : "%Y%m%d",    		// the date format
	      	button      : "startBtn"        // ID of the button
		});
		//改变是否永久生效时来确定是否显示有效日期
		function changeValidTag(validTag)
		{
			var validDateTr = document.getElementById("validDateTr");
			if(validTag == 'Y')
			{
				document.getElementById("validDate").value = "";
				validDateTr.style.display = "none";
			}
			else
			{
				validDateTr.style.display = "";
			}
		}
		//初始化方法
		function init()
		{
			var validTag = '${resultObject.validTag}';
			changeValidTag(validTag);
		}
		
		init();
	</script>
</html>